#include<iostream>
using namespace std;

void matrixSum(int mat1[][3], int mat2[][3], int n) {
    int sum[n][n];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            sum[i][j] = mat1[i][j] + mat2[i][j];
        }
    }

    cout << "矩阵和：" << endl;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << sum[i][j] << " ";
        }
        cout << endl;
    }
}

void matrixProduct(int mat1[][3], int mat2[][3], int n) {
    int product[n][n];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            product[i][j] = 0;
            for (int k = 0; k < n; k++) {
                product[i][j] += mat1[i][k] * mat2[k][j];
            }
        }
    }

    cout << "矩阵乘积：" << endl;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << product[i][j] << " ";
        }
        cout << endl;
    }
}

int main() {
    int mat1[][3] = {{1, 2, 3},
                     {2, 4, 5},
                     {3, 5, 6}};

    int mat2[][3] = {{1, 2, 1},
                     {2, 3, 2},
                     {1, 2, 3}};

    matrixSum(mat1, mat2, 3);
    cout << endl;
    matrixProduct(mat1, mat2, 3);

    return 0;
}